package com.mzy.linear_struct.subject;

/**
 * @Author: codermzy
 * @Date: 2024/04/26/下午8:50
 * @Description:
 */
public class 翻转二叉树226 {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }


    static class Solution {
        public TreeNode invertTree(TreeNode root) {
            if (root == null) {
                return null;
            }
            TreeNode left = root.left;
            root.left = root.right;
            root.right = left;

            invertTree(root.left);
            invertTree(root.right);
            return root;
        }
    }

    public static void main(String[] args) {

    }
}
